import java.util.Arrays;
public class Main {
    public static void main(String[] args) {
        int[]a={2,1,4,2,1,5,4,3,7,7,8,9};
        int count1=0;
        int count2=1;
        for(int i=0;i< a.length;i++){
            for(int j=0;j< a.length;j++){
                if(a[i]==a[j]){
                    count1++;
                }
            }
            if(count1==1){
                int tmp=a[i];
                for (int n=i;n>0;n--){
                    a[n]=a[n-1];
                }
                a[0]=tmp;
            }
            count1=0;
        }
        int clone_Array[] = a.clone();
        Arrays.sort(clone_Array);
        for(int n=0;n< clone_Array.length-1;n++){
            if(clone_Array[n]!=clone_Array[n+1]){
                count2++;
            }
        }
        System.out.println(count2);
        System.out.println(Arrays.toString(a));
    }
}